#ifndef DB_H
#define DB_H

#include <QObject>
#include <QSQLDatabase>
#include <QString>
#include <QThread>

class CDatabase: public QThread
{
	Q_OBJECT

private slots:
	void SetError(const QString &error, const QString &databaseType, const QString &connectionIdentifier);

protected:
	QString m_ConnectionIdentifier;

	QSqlDatabase m_Database;
	QString m_Error;

public:
	CDatabase();
	virtual ~CDatabase();

	virtual void run()																	{ }

	virtual QSqlDatabase *GetDatabase()													{ return &m_Database; }
	virtual	QString GetError() const													{ return m_Error; }
	virtual QString GetFileName() const													{ return QString::null; }

	virtual void SetThreadGoal(bool goal)												{ }

signals:
	void SetDatabase(bool open);
	void PrintConsoleThread(const QString &group, const QString &message, const QString &subGroup = QString(), bool error = 0);
};

#endif // DB_H
